package com.ym.ganio.gan;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by yumodev on 17/6/7.
 * 一个适配器基类
 */

public abstract class BaseRecyclerAdapter<VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter {
    public int TYPE_HEADER = 0;
    public int TYPE_FOOTER = 1;

    private View mFooterView;
    private View mHeaderView;

    public void setFooterView(View view){
        mFooterView = view;
    }

    public boolean hasFooter(){
        return mFooterView != null;
    }

    public void setHeaderView(View view){
        mHeaderView = view;
    }

    public boolean hasHeader(){
       return mHeaderView != null;
    }

    @Override
    public int getItemCount() {
        int count = 0;
        if (mFooterView != null) count++;
        if (mHeaderView != null) count++;
        return count;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        if (viewType == TYPE_FOOTER){
            mFooterView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
            return new FooterHolder(mFooterView);
        }else if (viewType == TYPE_HEADER){

        }
        return null;
    }

    public class FooterHolder extends RecyclerView.ViewHolder{
        public FooterHolder(View itemView) {
            super(itemView);
        }
    }

    public class HeaderHolder extends RecyclerView.ViewHolder{
        public HeaderHolder(View itemView) {
            super(itemView);
        }
    }
}
